package com.thinkingstar.iads.common.jsonUtils;

import java.io.Serializable;

/**
  * @ClassName: AjaxResult 
  * @Description: TODO(Aajx请求响应) 
  * @author int_java_se@163.com 
  * @date 2016年10月17日 上午9:39:27
 */
public class AjaxResult implements Serializable{

	private static final long serialVersionUID = 1L;
	
	/**
	 * 成功
	 */
	public static final int AJAX_STATUS_CODE_SUCCESS = 0;
	
	/**
	 * 警告
	 */
	public static final int AJAX_STATUS_CODE_WARN = 1;
	
	/**
	 * 异常
	 */
	public static final int AJAX_STATUS_CODE_ERROR = 2;
	
	/**
	 * 状态码
	 */
	private int statusCode;
	
	/**
	 * 响应消息
	 */
	private String message;
	
	/**
	 * 返回数据
	 */
	private Object data;
	
	/**
	 * 帮助链接
	 */
	private String helpAddress;
	
	public AjaxResult() {
		super();
	}
	
	/**
	 * 自定义返回格式
	 * @param statusCode 响应代码
	 * @param message  响应消息体
	 * @param data  响应数据
	 */
	public AjaxResult(int statusCode, String message) {
		super();
		this.statusCode = statusCode;
		this.message = message;
	}
	
	/**
	 * 自定义返回格式
	 * @param statusCode 响应代码
	 * @param message  响应消息体
	 * @param data  响应数据
	 */
	public AjaxResult(int statusCode, String message, Object data) {
		super();
		this.statusCode = statusCode;
		this.message = message;
		this.data = data;
	}

	
	/**
	 * 自定义返回格式
	 * @param statusCode 响应代码
	 * @param message  响应消息体
	 * @param data  响应数据
	 * @param helpAddress 帮助地址
	 */
	public AjaxResult(int statusCode, String message, Object data, String helpAddress) {
		super();
		this.statusCode = statusCode;
		this.message = message;
		this.data = data;
		this.helpAddress = helpAddress;
	}

	/**
	 * 操作执行成功
	 * @return AjaxResult
	 */
	public static AjaxResult success(){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_SUCCESS);
		ajaxResult.setMessage("SUCCESS");
		return ajaxResult;
	}
	/**
	 * 操作执行成功
	 * @param message 消息体
	 * @return AjaxResult
	 */
	public static AjaxResult success(String message){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_SUCCESS);
		ajaxResult.setMessage(message);
		return ajaxResult;
	}
	/**
	 * 操作执行成功
	 * @param data 传输数据
	 * @return AjaxResult
	 */
	public static AjaxResult success(Object data){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_SUCCESS);
		ajaxResult.setMessage("SUCCESS");
		ajaxResult.setData(data);
		return ajaxResult;
	}
	/**
	 * 操作执行异常
	 * @return AjaxResult
	 */
	public static AjaxResult error(){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_ERROR);
		ajaxResult.setMessage("ERROR");
		return ajaxResult;
	}
	/**
	 * 操作执行异常
	 * @param message 消息体
	 * @return AjaxResult
	 */
	public static AjaxResult error(String message){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_ERROR);
		ajaxResult.setMessage(message);
		return ajaxResult;
	}
	/**
	 * 操作执行异常
	 * @param data 传输数据
	 * @return AjaxResult
	 */
	public static AjaxResult error(Object data){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_ERROR);
		ajaxResult.setMessage("ERROR");
		ajaxResult.setData(data);
		return ajaxResult;
	}
	/**
	 * 操作执行警告
	 * @return AjaxResult
	 */
	public static AjaxResult warn(){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_WARN);
		ajaxResult.setMessage("WARN");
		return ajaxResult;
	}
	/**
	 * 操作执行警告
	 * @param message 消息体
	 * @return AjaxResult
	 */
	public static AjaxResult warn(String message){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_WARN);
		ajaxResult.setMessage(message);
		return ajaxResult;
	}
	/**
	 * 操作执行警告
	 * @param data 传输数据
	 * @return AjaxResult
	 */
	public static AjaxResult warn(Object data){
		AjaxResult ajaxResult = new AjaxResult();
		ajaxResult.setStatusCode(AJAX_STATUS_CODE_WARN);
		ajaxResult.setMessage("WARN");
		ajaxResult.setData(data);
		return ajaxResult;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	public String getHelpAddress() {
		return helpAddress;
	}

	public void setHelpAddress(String helpAddress) {
		this.helpAddress = helpAddress;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public static int getAjaxStatusCodeSuccess() {
		return AJAX_STATUS_CODE_SUCCESS;
	}

	public static int getAjaxStatusCodeWarn() {
		return AJAX_STATUS_CODE_WARN;
	}

	public static int getAjaxStatusCodeError() {
		return AJAX_STATUS_CODE_ERROR;
	}
	
}
